<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>体检人列表</title>
    <link rel="stylesheet" href="/font/font_1/iconfont.css">
    <style>
        body {
            background-color: #f1f1f1;
            padding: 1rem;
            position: relative;
        }
        
        * {
            margin: 0;
            padding: 0;
            list-style: none;
        }
        
        .box {
            width: 100%;
            border-radius: 10px;
        }
        
        ul {
            width: 100%;
        }
        
        li {
            width: 100%;
            padding: 1rem;
            box-sizing: border-box;
            box-shadow: 0px 20px 20px 0px rgba(225, 225, 225, 0.8);
            margin-bottom: 10px;
            background-color: #fff;
            border-radius: 10px;
        }
        
        li>div {
            display: flex;
            align-items: center;
            margin-top: 10px;
        }
        
        li>a {
            font-size: 14px;
            color: red;
            text-decoration: underline;
        }
        
        .left {
            margin-right: 15px;
        }
        
        p {
            font-size: 15px;
            margin-bottom: 5px;
        }
        
        li img {
            width: 50px;
            height: 50px;
            border-radius: 50%;
        }
        
        p>strong {
            width: 4.5rem;
            display: inline-block;
            text-align: right;
            font-weight: 500;
        }
        
        .box>li {
            text-align: center;
            flex-wrap: wrap;
        }
        
        .box>li>p {
            width: 100%;
        }
        
        .box>li>p .iconfont {
            font-size: 35px;
            color: #ccc;
        }
        /* 确认解除样式 */
        
        .show {
            width: 90%;
            height: 15rem;
            background-color: #f1f1f1;
            position: fixed;
            top: 50%;
            left: 50%;
            margin-top: -9rem;
            margin-left: -45%;
            padding: 1rem;
            box-sizing: border-box;
            display: flex;
            flex-wrap: wrap;
            display: none;
        }
        
        .show-top {
            border-bottom: 1px solid #ccc;
            font-size: 20px;
            font-weight: 700;
            padding: 1rem;
            width: 100%;
        }
        
        .show_center {
            padding: 1rem;
            width: 100%;
        }
        
        .show-bottom {
            padding: 1rem;
            width: 100%;
            box-sizing: border-box;
        }
        
        .show-bottom button {
            margin-left: 1rem;
            width: 30%;
            height: 2rem;
            float: right;
            background-color: #3B97FD;
            border: none;
            border: 1px solid #ccc;
            color: #fff;
        }
        /* 默认选中样式 */
        
        .color {
            border: 1px solid lime;
        }
        
        li>span {
            font-size: 15px;
        }
    </style>
</head>

<body>
    <div class="box">
        <ul>
        </ul>
        <li class="binDing">
            <p><i class="iconfont icon-tianjia"></i></p>
            <p>添加</p>
        </li>
    </div>

    <script src="/js/jquery-3.6.0.min.js"></script>
    <script src="/js/config.js"></script>
    <script>
        $('.binDing').click(function() {
            window.location.href = `addbinding?username=${theRequest.username}&Authorization=${Authorization}`
        })
        var title = localStorage.getItem(('title'));
        var settings = {
            "url": `http://58.210.112.60:38102/Wechat/Api/GetArchiveList?username=${theRequest.username}`,
            "method": "GET",
            "timeout": 0,
            "headers": {
                "Authorization": Authorization,
                "Accept": "*/*",
            },
        };

        $.ajax(settings).done(function(response) {
                    let teplhtml = `
        ${response.data.map(item=>{
                return ` <li class="${theRequest.IdentityNo==item.IdentityNo?'color':""}">
                <a>解除体检人绑定</a>
                <span ${theRequest.IdentityNo==item.IdentityNo?'style="display: block"':'style="display: none;"'}>当前选定</span>
                <div class="skip">
                <div class="left">
                    <img src="/img/微信图片_20230320095233.jpg" alt="">
                </div>
                <div class="right">
                    <p><strong>身份证号:</strong> <span class="IdentityNo">${item.IdentityNo}</span> </p>
                    <p><strong>手机号:</strong> <span class='Tel'>${item.Tel}</span></p>
                    <p><strong>姓名:</strong> <span class='FullName'>${item.FullName}</span></p>
                    <p><strong>绑定关系:</strong> <span class="Relationship">${item.Relationship}</span></p>
                </div>
                </div>
                <div class="show">
        <div class="show-top">
            <p>解除体检人绑定</p>
        </div>
        <div class="show_center">
            <p>确定要解除该体检人信息吗</p>
        </div>
        <div class="show-bottom">
            <button class="confirm">确定</button>
            <button class="cancel">取消</button>
        </div>
    </div>
            </li>`
            }).join('')
        }
    `

            $('.box ul').html(teplhtml);
            $('.box ul li .skip').click(function () {
                var IdentityNo = $(this).find('.right').find('.IdentityNo').text();
                const tel = $(this).find('.right').find('.Tel').text();
                const FullName = $(this).find('.right').find('.FullName').text();
                const Relationship = $(this).find('.right').find('.Relationship').text();
                const list = {
                    tel: tel,
                    FullName: FullName,
                    Relationship: Relationship,
                    IdentityNo: IdentityNo,
                    username: theRequest.username
                }
                localStorage.setItem('title', JSON.stringify(list));
                window.location.href = `home?Authorization=${Authorization}&IdentityNo=${IdentityNo}`
            });
            $('.box ul li>a').click(function () {
                var IdentityNo = $(this).next().find('.IdentityNo').text();
                $(this).parent().find('.show').css('display', 'block');
                $(this).parent().find('.show').find('.confirm').click(function () {
                    const settings = {
                        "url": `${Url}/Wechat/Api/UnLinkArchive`,
                        "method": "POST",
                        "timeout": 0,
                        "headers": {
                            "Authorization": Authorization,
                            "Content-Type": "application/json",
                            "Accept": "*/*",
                        },
                        "data": JSON.stringify({
                            "username": theRequest.username,
                            "identityNo": IdentityNo
                        }),
                    };

                    $.ajax(settings).done(function (response) {
                        if (response.code == 200) {
                            location.reload()
                        }
                    });
                })
                $(this).parent().find('.show').find('.cancel').click(function(){
                    $('.show').css('display','none')
                })

            })
        });
    </script>
</body>

</html>